#include "main/utils.h"
using namespace std;

int occurOneTime(const vector<int> &vec) {
  vector<int> times(32, 0);
  for (int i = 0; i < vec.size(); ++i) {
    for (int j = 0; j < 32; ++j) {
      if (vec[i] & (1 << j)) {
        ++times[j];
      }
    }
  }

  int ret = 0;
  for (int i = 0; i < 32; ++i) {
    if (times[i] % 3) {
      ret = ret | (1 << i);
    }
  }

  return ret;
}

int main() {
  vector<int> input = {0, 1, 0, 1, 0, 1, 100};
  int ret = occurOneTime(input);
  cout << "The number occur once, others occur three times: " << ret << endl;

  return 0;
}
